package com.example.employeemanagement.service.impl;

import com.example.employeemanagement.entry.Position;
import com.example.employeemanagement.mapper.PositionMapper;
import com.example.employeemanagement.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PositionServiceImpl implements PositionService {
    @Autowired
    private PositionMapper positionMapper;

    @Override
    public List<Position> getAllPositions() {
        return positionMapper.getAllPositions();
    }

    @Override
    public Position getPositionById(Integer positionId) {
        return positionMapper.getPositionById(positionId);
    }

    @Override
    public String addPosition(Position position) {
        int result = positionMapper.addPosition(position);
        return result > 0 ? "职位添加成功" : "职位添加失败";
    }

    @Override
    public String updatePosition(Position position) {
        int result = positionMapper.updatePosition(position);
        return result > 0 ? "职位更新成功" : "职位更新失败";
    }

    @Override
    public String deletePosition(Integer positionId) {
        int result = positionMapper.deletePosition(positionId);
        return result > 0 ? "职位删除成功" : "职位删除失败";
    }
}